const baseURL = 'http://nocat.life:3017';

const request = async (url, method, data, isLoading = true) => {

	if (isLoading) {
		uni.showLoading({
			title: '加载中'
		});
	}

	const res = await uni.request({
		url: baseURL + url,
		method,
		data,
		timeout: 3000,
		header: {
			Authorization: uni.getStorageSync('user_token')
		}
	});

	uni.hideLoading();

	return res.data;
}


export const httpGet = (url, data, isLoading) => {
	return request(url, 'GET', data, isLoading);
}
export const httpPost = (url, data, isLoading) => {
	return request(url, 'POST', data, isLoading);
}
export const httpDelete = (url, data, isLoading) => {
	return request(url, 'DELETE', data, isLoading);
}
export const httpPut = (url, data, isLoading) => {
	return request(url, 'PUT', data, isLoading);
}